package com.yunhe.transfer.client.fallback;

import com.yunhe.common.model.authority.Station;
import com.yunhe.transfer.client.AuthorityClient;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.StationDTO;
import com.yunhe.common.util.FallbackUtil;
import feign.hystrix.FallbackFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AuthorityFallbackFactory implements FallbackFactory<AuthorityClient> {
    @Override
    public AuthorityClient create(Throwable cause) {
        return new AuthorityClient() {
            @Override
            public ResultObject<List<Station>> getStations(Long userId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResultObject<Station> getStationById(Long stationId) {
                return FallbackUtil.getDefaultFallBack();
            }

            @Override
            public ResponseEntity<ResultObject<Station>> getStationByCode(Long code) {
                return FallbackUtil.getDefaultFallBack();
            }
        };
    }
}
